// AlsaCore.cpp - Wrapper for ALSA library to record and play wave files

#include <iostream>
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <fcntl.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <time.h>
#include <locale.h>
#include <assert.h>
#include <termios.h>
#include <signal.h>
#include <output.h>
#include <sys/poll.h>
#include <sys/uio.h>
#include <sys/time.h>
#include <sys/signal.h>
#include <asm/byteorder.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <libintl.h>
#include <endian.h>
#include <byteswap.h>
#include <math.h>
#include <pthread.h>
#include "gettext.h"
#include "formats.h"
#include "version.h"
#include "RingBuffer.h"
#include "AlsaPlayers.h"

// Play a raw PCM sound buffer
AlsaPcmBufferPlayer::AlsaPcmBufferPlayer()
{
}

AlsaPcmBufferPlayer::~AlsaPcmBufferPlayer()
{
}

int AlsaPcmBufferPlayer::PlayPcmBuffer(unsigned char* buffer, int size)
{
	off64_t written = 0;

	file_type = FORMAT_RAW;
	stream = SND_PCM_STREAM_PLAYBACK;
	command = (char *)"aplay";
	rhwparams.format = SND_PCM_FORMAT_S16_LE;
	rhwparams.rate = 16000;
	rhwparams.channels = 1;

	set_play_params();
	written = pcm_write(buffer, size);

	return (written);
}
